#from django.template.loader import get_template
from django.template import Context
from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.core.mail import send_mail
import datetime
import MySQLdb
from mysite.blog.models import *

def hello(request):
	return HttpResponse("Hello Yingcai")
def welcome(request):
	return HttpResponse("<html><center>Yingcai</center></thml>")

def current_time(request):
	#now = datetime.datetime.now()
	#t = get_template('current_datetime.html')
	#html = t.render(Context({'current_date': now}))
	#return HttpResponse(html)
	#return render_to_response('current_datetime.html', {'current_date': now})
	current_date = datetime.datetime.now()
	return render_to_response('current_datetime.html',locals())
def hours_ahead(request,offset):
	hour_offset = int(offset)
	next_time = datetime.datetime.now() + datetime.timedelta(hours=hour_offset)
	return render_to_response('offset_time.html',locals())
def book(request):
	db = MySQLdb.connect(user='root', db='wordpress', passwd='168668', host='localhost')
	cursor = db.cursor()
	cursor.execute('select post_title from wp_posts')
	post = [row[0] for row in cursor.fetchall()]
	db.close()
	return render_to_response('book_list.html', {'post': post})


